<?php
$mysql_server_name="localhost"; 
$mysql_username="zj1024";
$mysql_password="z123456789";
$mysql_database="chenchuedu";

header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept,USER_ID,TOKEN");
header("Access-Control-Allow-Methods:HEAD, GET, POST, DELETE, PUT, OPTIONS");
header("Content-Type: text/html; charset=utf-8");

$conn=mysql_connect($mysql_server_name, $mysql_username,$mysql_password);
if(!$conn){
	die('connect failed!');
}
mysql_select_db($mysql_database, $conn);

mysql_query("SET NAMES utf8");

$result = mysql_query("SELECT * FROM userinfo");
$json ="";
$data =array(); 
class User{
	public $id;
	public $name;
	public $tel;
	public $type;
	public $time;
}

while ($row= mysql_fetch_array($result, MYSQL_ASSOC)){
	$user =new User();
	$user -> id   = $row['id'];
	$user -> name = $row["name"];
	$user -> tel  = $row['tel'];
	$user -> type = $row['type'];
	$user -> time = $row['time'];
	$data[]=$user;
}
$json = json_encode($data);
echo "{".'"user"'.":".$json."}";
mysql_close($conn);
?>